<?php
    error_reporting(E_ALL ^ E_NOTICE);
    include './includes/connect.php';
    $query2 = "SELECT * FROM articoli ORDER BY id DESC";
    $risultato = mysql_query($query2);
    $query3 = "SELECT * FROM info"; 
    $risultato2 = mysql_query($query3);
    if (mysql_num_rows($risultato2)>0){
        $row = mysql_fetch_array($risultato2);
        $nome = $row['blog_nome'];
        $url = $row['blog_url'];
    }
    require_once("feedcreator.class.php"); 
    $rss = new UniversalFeedCreator(); 
    $rss->useCached(); 
    $rss->title = $nome; 
    $rss->description = "Segui gli aggiornamenti abboanandoti al feed rss"; 
    $rss->link = $url;
    $rss->feedURL = $url . "feed.php"; 
    function xmlentities ( $string ) {
        $ar1 = array ( '&' , '&quot;', '&apos;' , '&lt;' , '&gt;' );
        $ar2 = array ( '&', '"', "’", '<', '>' ) ;
        return str_replace ( $ar1 , $ar2, $string );
    }
    while ($data=mysql_fetch_array($risultato)) { 
        $data['titolo'] = xmlentities($data['titolo']);
        $data['articolo'] = xmlentities($data['articolo']);
        $item = new FeedItem(); 
        $item->title = $data['titolo'];
        $item->link = $url. "articolo.php?id=".$data['id'] ;
        $item->description = $data['articolo'];
        $item->author = $mail;
        $item->descriptionHtmlSyndicated = true;
        $item->categoryHtmlSyndicated = true;
        item->descriptionTruncSize = 500;

        $rss->addItem($item);
    } 
    echo $rss->createFeed("RSS2.0", "");
?>